define(function() {

	//the assets
	var assets = [];
	var extFolderClassMap = []; // ".jpg" => ['tex', Texture]
	
	function getExtension(name) {
		return name.substring(name.lastIndexOf('.') + 1);
	};
	
	function resolvePath(name) {
		var ext = getExtension(name);
		var folderPath = (extFolderClassMap[ext])[0];
		return folderPath + name;
	};
	
	function resolveClass(name) {
		var ext = getExtension(name);
		return (extFolderClassMap[ext])[1];
	};
	
	return {
		
		//Map extension to folder and class
		mapExt : function(extName, extFolder, assetClass) {
			extFolderClassMap[extName] = [extFolder, assetClass];
		},
		
		//Get asset, will load if necessary
		get : function(name, callback, params) {
			var path 	= resolvePath(name);
			var assetCl	= resolveClass(name);
			var asset 	= assets[path];
			if(!asset) {
				assets[path] = asset = assetCl.create(path);
			}
			asset.incRef(callback, params);
			
			return asset;
		},
		
		//Release asset,
		let : function(asset) {
			asset.decRef();
		}
	};
});